package routes

import (
	"github.com/gin-gonic/gin"
	"github.com/jmoiron/sqlx"
	"hysx/controllers"
	"hysx/repositories"
	"hysx/services"
	"hysx/utils"
)

// Init{{.StructName}}Routes 初始化{{.TableComment}}模块路由
func Init{{.StructName}}Routes(router *gin.Engine, db *sqlx.DB) {
	// 仓库加载数据库
	{{.TabName}}Repository := repositories.Register{{.StructName}}Repository(db)
	// 服务加载仓库
	{{.TabName}}Service := services.New{{.StructName}}Service({{.TabName}}Repository)
	// 控制器加载服务
	{{.TabName}}Controller := controllers.New{{.StructName}}Controller({{.TabName}}Service)

    //添加权限验证
	{{.TabName}}Routes := router.Group("/{{.TabName}}",utils.Authority())
	{
		{{.TabName}}Routes.POST("", {{.TabName}}Controller.Add{{.StructName}}Handler)
		{{.TabName}}Routes.DELETE(":id", {{.TabName}}Controller.Remove{{.StructName}}Handler)
		{{.TabName}}Routes.PUT("", {{.TabName}}Controller.Modify{{.StructName}}Handler)
		{{.TabName}}Routes.GET(":id", {{.TabName}}Controller.Get{{.StructName}}ByIdHandler)
		{{.TabName}}Routes.GET("", {{.TabName}}Controller.Get{{.StructName}}ListHandler)
		{{.TabName}}Routes.GET("/export", {{.TabName}}Controller.Export{{.StructName}}Handler)
		{{.TabName}}Routes.POST("/import", {{.TabName}}Controller.Import{{.StructName}}Handler)
		{{.TabName}}Routes.GET("/downloadTempl", {{.TabName}}Controller.DownloadImportTemplate)
	}
}
